<template>
	<!-- 已签门店 -->
	<view class="wp">
		<view class="nav_bar">
			<view class="serch">
				<uni-search-bar class="input" radius="50" placeholder="搜索门店" clearButton="none" cancelButton="none"
					v-model="formData.keyword" @confirm="search" />
				<text class="screen" @click="openScreen">筛选 <text class="yticon icon-you"></text></text>
			</view>
			<!-- <view class="number">共{{info.num}}条结果</view> -->
		</view>
		<view class="body">
			<view class="list_item" v-for="(item,idx) in list" :key="idx"
				@click="$navTo('../shoplist/shopgoods?id='+item.uid)">
				<view class="top">
					<image :src="item.logo" mode=""></image>
					<view class="right">
						<view class="title">
							<text class="t_tag">{{item.typestr}}</text>
							<text class="name">
								{{item.supname}}
							</text>
							<text class="label">{{item.name}}</text>
						</view>
						<view class="money">
							<view class="m_li">
								<text>累计完成交易笔数：</text>
								<text class="number">{{item.totalnum}}</text>
							</view>
						</view>
						<view class="money">
							<view class="m_li">
								<text>累计获得佣金：</text>
								<text class="number">{{item.totalmoney}}</text>
							</view>
						</view>
						<button v-if="item.empower==1" size="mini" type="default" @click.stop="$navTo('/pages/business/personalstores?uid='+item.uid+'&isempower=1')">修改信息</button>
					</view>
				</view>
				<view class="middle">
					<view>直推粉丝：<text class="m_num">{{item.members.allnum}}</text>今日新增：<text class="m_num">{{item.members.todaynum}}</text>昨日新增：<text class="m_num">{{item.members.yesdaynum}}</text></view>
					<view>买单收入：<text class="m_num">{{item.order.allmoney}}</text>商品数量：<text class="m_num">{{item.order.goodsnum}}</text></view>
					<view>团购收入：<text class="m_num">{{item.group.allmoney}}</text>团购数量：<text class="m_num">{{item.group.allnum}}</text></view>
				</view>
				<button class="examine" size="mini" type="warn" @click.stop="examine(item.uid,idx)" v-if="item.checkstatus!=1&&isShow">通过审核</button>
				<view class="bottom">
					<view class="b_left">
						<text class="Entry_time">入驻时间：{{item.checktime}}</text>
					</view>
					<view class="b_left">
						<text class="Entry_time">业务经理：{{item.nickname}}</text>
					</view>
				</view>
			</view>
			<view class="empty">
				<image v-if="isloading" src="../../static/business/loading.gif" mode=""></image>
				<text v-if="!ismore">到底了~</text>
			</view>
		</view>

		<uni-drawer ref="showRight" mode="right" :mask-click="true">
			<scroll-view class="scroll_screen" :scroll-y="true">
				<uni-forms :modelValue="formData" label-width="120px" label-position="top">
					<uni-forms-item label="所属类目">
						<uni-data-select v-model="formData.industry" :localdata="info.industrys"
							:clear="false"></uni-data-select>
					</uni-forms-item>
					<uni-forms-item label="入驻起始日期">
						<view class="data_time" @click="openPicker('begintime')">
							<text v-if="formData.begintime">{{formData.begintime}}</text>
							<text v-else>选择日期</text>
						</view>
					</uni-forms-item>
					<uni-forms-item label="入驻截止日期">
						<view class="data_time" @click="openPicker('endtime')">
							<text v-if="formData.endtime">{{formData.endtime}}</text>
							<text v-else>选择日期</text>
						</view>
					</uni-forms-item>
					<uni-forms-item label="实收营业额">
						<uni-easyinput type="number" :clearable="false" v-model="formData.price" placeholder="营业额" />
					</uni-forms-item>
					<uni-forms-item label="消费天数">
						<uni-easyinput type="number" :clearable="false" v-model="formData.saleday" placeholder="消费天数" />
					</uni-forms-item>
					<uni-forms-item label="剩余额度">
						<uni-easyinput type="number" :clearable="false" v-model="formData.usemoney"
							placeholder="剩余额度" />
					</uni-forms-item>
					<view class="screen_submit">
						<button @click="screenSubmit">确定筛选</button>
					</view>
					<view class="block"></view>
				</uni-forms>
			</scroll-view>
		</uni-drawer>
		<simple-datetime-picker ref="myPicker" :startYear="2023" :isd="true" :endYear="endYear"
			@submit="handleSubmit"></simple-datetime-picker>
	</view>
</template>

<script>
	import SimpleDateTimePicker from '@/components/simple-datetime-picker/simple-datetime-picker.vue'
	export default {
		components: {
			SimpleDateTimePicker
		},
		data() {
			let date = new Date(),
				year = date.getFullYear();
			return {
				endYear: year,
				setDataTime: '',
				formData: {
					industry: '',
					begintime: '',
					endtime: '',
					price: '',
					saleday: '',
					usemoney: '',
					keyword: '',
				},
				info: {
					industrys: [{
						value: '',
						text: "全部"
					}],
					num: "0"
				},
				page: 0,
				list: [],
				isloading: false,
				ismore: true,
				isShow: false,
			}
		},
		onLoad(option) {
			this.formData.price = option.price ? option.price : this.formData.price;
			this.getInfo();
			this.getList();
			let level = uni.getStorageSync('level');
			if(level['5'] || level['6']){
				this.isShow = true;
			}else{
				this.isShow = false;
			}
		},
		onReachBottom() {
			this.getList();
		},
		methods: {
			examine(uid, idx){
				let that = this;
				uni.showModal({
					title: '提示',
					content: '确认通过审核？',
					success: function (res) {
						if (res.confirm) {
							that.$axios('refershop/checkSup', 'POST', 'member', {
								uid
							}).then(res=>{
								if(res.data.code == 200){
									that.$api.msg(res.data.data);
									that.list[idx].checkstatus = 1;
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			getInfo() {
				this.$axios('signing/main', 'POST', 'member', this.formData).then(res => {
					if (res.data.code == 200) {
						let obj = res.data.data.industrys.map(v => ({
							value: v.id,
							text: v.name
						}))
						this.info.industrys = [...this.info.industrys, ...obj];
					}
				})
			},
			getList() {
				this.page++;
				let obj = {
					...this.formData,
					page: this.page
				}
				this.isloading = true;
				this.ismore = true;
				this.$axios('refershop/lists', 'POST', 'member', obj).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.list = [...this.list, ...res.data.data];
						this.ismore = res.data.data.length > 0;
					}
				})
			},
			search() {
				this.page = 0;
				this.list = [];
				this.getList();
			},
			openScreen() {
				this.$refs.showRight.open();
			},
			screenSubmit() {
				this.$refs.showRight.close();
				this.search();
			},
			handleSubmit(e) {
				if (!this.setDataTime) return;
				this.formData[this.setDataTime] = `${e.year}-${e.month}-${e.day}`;
			},
			openPicker(v) {
				this.setDataTime = v;
				this.$refs.myPicker.show();
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
		color: #303133;
	}

	.wp {
		letter-spacing: 1px;
	}

	.nav_bar {
		background: #fff;
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 100;

		.serch {
			display: flex;
			align-items: center;

			.input {
				flex: 1;
			}

			.screen {
				font-size: 32upx;
				padding-right: 10px;

				text {
					display: inline-block;
					transform: rotateZ(90deg);
				}
			}
		}

		.number {
			font-weight: bold;
			line-height: 24px;
			padding: 0 10px 10px;
		}
	}

	.body {
		padding: 66px 0;

		.list_item {
			background: #fff;
			border-radius: 15upx;
			margin-bottom: 10px;
			padding: 20upx;

			.top {
				display: flex;

				image {
					border-radius: 15upx;
					height: 135upx;
					width: 135upx;
				}

				.right {
					line-height: 45upx;
					padding-left: 20upx;
					width: calc(100% - 135upx);
					position: relative;
					.title {
						color: #000;
						display: flex;
						align-items: center;
						font-size: 32upx;
						.t_tag{
							border: 1rpx solid $bg-color;
						    color: $bg-color;
						    font-size: 22rpx;
						    border-radius: 8rpx;
						    padding: 0 6rpx;
						    margin-right: 10rpx;
							line-height: 1.5;
							white-space: nowrap;
						}
						.name {
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							padding-right: 20upx;
							width: calc(100% - 155upx);
							.t_tag{
								
							}
						}

						.label {
							border: 1px $bg-color solid;
							border-radius: 10upx;
							color: $bg-color;
							flex: 1;
							font-size: 28upx;
							text-align: center;
							white-space: nowrap;
						}
					}
					button{
						margin: 0;
						position: absolute;
						right: 0;
						bottom: 10rpx;
					}
					.money,
					.m_li {
						color: #666;
						display: flex;
						align-items: center;
						justify-content: space-between;

						.m_li {
							justify-content: flex-start;

							.number {
								color: #000;
							}
						}
					}


				}
			}
			.examine{
				float: right;
				margin-top: -74rpx;
				background: rgb(9, 72, 1);
			}
			.bottom,
			.b_left {
				color: #666;
				display: flex;
				align-items: center;
				justify-content: space-between;
			}
			.middle{
				margin: 5rpx 0;
			    color: #666;
			    font-size: 26rpx;
			    line-height: 1.5;
					.m_num{
						margin-right: 20rpx;
						color: #333;
					}
			}
			.bottom {
				// padding-top: 20upx;

				.b_left {
					font-size: 32upx;
				}

				.b_e {
					color: rgb(20, 15, 145);
					width: 155upx;
				}

				.number {
					text {
						color: $bg-color;
					}
				}
			}
		}
	}

	.scroll_screen {
		height: 100vh;
	}

	.uni-forms {
		padding: 0 20upx;
	}

	.uni-forms .uni-forms-item__label {
		padding-bottom: 0 !important;
	}

	.uni-forms .uni-forms-item {
		margin-bottom: 10px;
	}
	.Entry_time {
		color: #666;
		font-size: 11px;
	}
	.data_time {
		border: 1px solid #e5e5e5;
		border-radius: 4px;
		color: #666;
		font-size: 10px;
		height: 35px;
		line-height: 35px;
		padding: 0 10px;
	}

	.screen_submit {
		padding-top: 50upx;
		text-align: center;

		button {
			background: $bg-color;
			color: #fff;
			line-height: 90upx;
			height: 90upx;
			font-size: 34upx;
			letter-spacing: 1px;
		}
	}

	.block {
		height: 100upx;
	}

	.empty {
		image {
			height: 60upx;
			width: 60upx;
		}

		text-align: center;
		color: #4399fc;
	}
</style>